<template>
	<view>
		<view class="choose-community">
			<view class="current-location">
				<view class="title">
					房屋信息
				</view>
				<view class="content">
					<text>{{roomInfo}}</text>
				</view>
			</view>
			<view class="community">
				<view class="title">
					业主信息
				</view>
				<u--form labelAlign="left" ref="uForm">
					<u-form-item label="姓名" borderBottom labelWidth="208rpx">
						<u--input v-model="form.username" border="none" placeholder="请填写您的真实姓名"
							placeholderStyle="font-size:28rpx;color:#C3C3C5"></u--input>
					</u-form-item>
					<u-form-item label="性别" borderBottom labelWidth="208rpx">
						<u-radio-group v-model="value" placement="row">
							<u-radio activeColor="#5591AF" label="男"></u-radio>
							<u-radio activeColor="#5591AF" label="女"></u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="手机号" borderBottom labelWidth="208rpx">
						<u-input v-model="form.mobile" border="none" placeholder="请输入您的手机号"
							placeholderStyle="font-size:28rpx;color:#C3C3C5">
							<view slot="suffix">
								<u-count-down @finish="onFinish" v-if="isShowCountDown" :time="6 * 1000" format="ss s">
								</u-count-down>
								<view @click="getCode" class="code-btn" v-else>获取验证码</view>
							</view>
						</u-input>
					</u-form-item>
					<u-form-item label="验证码" borderBottom labelWidth="208rpx">
						<u--input v-model="form.code" border="none" placeholder="请输入手机验证码"
							placeholderStyle="font-size:28rpx;color:#C3C3C5"></u--input>
					</u-form-item>
				</u--form>
			</view>
			<u-cell-group customStyle="backgroundColor:#fff;margin-top:15rpx;height:860rpx" border="false">
				<u-cell title="上传本人身份证照片">
					<text slot="label" class="labelStyle">请拍摄证件原件，并使照片中证件边缘完整，文字清晰，光线均匀。</text>
				</u-cell>
				<u-upload :fileList="fileList6" @afterRead="afterRead" @delete="deletePic" name="6" multiple
					:maxCount="1">
					<view class="IdCard">
						<image src="../../static/icon/add.png"></image>
						<text>上传人像面照片</text>
					</view>
					<view class="IdCard">
						<image src="../../static/icon/add.png"></image>
						<text>上传国徽面照片</text>
					</view>
				</u-upload>
			</u-cell-group>
		</view>
		<!-- 提交审核 -->
		<view class="commit">
			<image src="../../static/icon/check.png"></image>
			<text>提交审核</text>
		</view>
	</view>

</template>

<script>
	import {
		sendCode
	} from '../../api/login.js'
	export default {
		data() {
			return {
				roomInfo: this.$store.state.house.roomInfo,
				form: {
					username: '',
					gender: '',
					mobile: '',
					code: ''
				},
				isShowCountDown: false,
			}
		},
		methods: {
			// 获取验证码
			getCode() {
				// 校验手机号
				this.$refs.uForm.validateField('mobile', async (errRes) => {
					if (errRes.length) return
					// 手机号合法，发请求
					const res = await sendCode(this.form.mobile)
					// console.log(res);
					// message
					const message = `【享+生活】验证码：${res.data.code}.您正在使用短信验证码功能，验证码提供他人可能导致账号被盗，请勿转发或泄漏。`
					this.code = res.data.code
					// 短信提示
					// this.$refs.uNotify.show({
					// 	top: 10,
					// 	type: 'success',
					// 	message: message,
					// 	duration: 1000 * 6,
					// 	fontSize: 14
					// })
					// 震动
					// uni.vibrateLong()
					// 显示倒计时
					this.isShowCountDown = true
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.choose-community {
		height: 100%;
		background-color: #FAFAFA;
		padding-bottom: 213rpx;

		.current-location {
			.title {
				padding: 15rpx 15rpx;
				line-height: 43rpx;
				color: #979797;
				font-family: PingFang SC;
				font-weight: regular;
				font-size: 12px;
			}

			.content {
				width: 750rpx;
				height: 102rpx;
				background-color: #fff;
				box-sizing: border-box;
				padding: 0 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				text {
					font-size: 28rpx;
					color: #333;
				}
			}
		}

		.community {
			.title {
				padding: 15rpx 15rpx;
				line-height: 43rpx;
				color: #979797;
				font-family: PingFang SC;
				font-weight: regular;
				font-size: 12px;
			}

			::v-deep .u-form {
				background-color: #fff;

				.u-form-item__body__left {
					margin-left: 30rpx;
				}

				.u-radio {
					margin-right: 60rpx;
				}

				.code-btn {
					color: #5591AF;
					font-size: 28rpx;
					margin-right: 30rpx;
				}
			}
		}

		.editHome {
			height: 213rpx;
			width: 750rpx;
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			background-color: #fff;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			image {
				width: 50rpx;
				height: 50rpx;
				margin-bottom: 10rpx;
			}

			.text {
				color: #333333;
				font-family: PingFang SC;
				font-weight: regular;
				font-size: 30rpx;
				line-height: 1.5;
				text-align: left;
			}
		}

		.labelStyle {
			font-size: 22rpx;
			color: #C3C3C5;
		}

		::v-deep .u-upload {
			// margin-bottom: 275rpx;
			// overflow: hidden;

			.IdCard {
				width: 690rpx;
				height: 340rpx;
				margin: 20rpx 30rpx;
				background-color: #FAFAFA;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				image {
					width: 50rpx;
					height: 50rpx;
				}

				text {
					color: #7694B0;
					font-size: 30rpx
				}
			}
		}
	}

	.commit {
		width: 750rpx;
		height: 213rpx;
		margin-top: 62rpx;
		background-color: #fff;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		image {
			width: 50rpx;
			height: 50rpx;
		}
	}
</style>
